package readURL; 

import java.io.*;
import java.net.*;
public class OpenStreamTest2 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
        try {
        	if (args.length < 1) {
        		System.out.println("usage: java OpenStreamTest2 url-string"); 
        		System.exit(0);
        	}
//          URL yahoo = new URL("http://www.yahoo.com/");
        	URL url = new URL("http://" + args[0]); 
            DataInputStream dis;
            BufferedReader br; 
            InputStreamReader isr; 
            String inputLine;

            dis = new DataInputStream(url.openStream());
            isr = new InputStreamReader(dis); 
            br = new BufferedReader(isr); 
            while ((inputLine = br.readLine()) != null) {
                System.out.println(inputLine);
            }
            dis.close();
        } catch (MalformedURLException me) {
            System.out.println("MalformedURLException: " + me);
        } catch (IOException ioe) {
            System.out.println("IOException: " + ioe);
        }
	}

}
